package com.ydd.service.impl;

import com.github.pagehelper.PageHelper;
import com.ydd.entity.SysRole;
import com.ydd.mapper.RoleMapper;
import com.ydd.service.RoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

@Service
@Slf4j
public class RoleServiceImpl implements RoleService {

    @Autowired
    private RoleMapper roleMapper;

    /**
     * 角色分页
     * @param sysRole
     * @param page
     * @param limit
     * @return
     */
    @Override
    public List<SysRole> page(SysRole sysRole, Integer page, Integer limit) {
        if(Objects.isNull(sysRole)) {
            throw new RuntimeException("非法参数");
        }

        PageHelper.startPage(page, limit);
        List<SysRole> sysRoles = roleMapper.selectByCondition(sysRole);

        return sysRoles;
    }
}
